#统计字符串中的单词个数，这里的单词指的是连续的不是空格的字符。
class Solution:
    def countSegments(self, s: str) -> int:
        n = len(s)
        a = 0
        for i in range(0,n):
            if (i == 0 or s[i-1] == " ") and s[i] != " ":
                a += 1
        return a